package com.opennews.openplatform

import com.opennews.openplatform.security.AuthRequestValidator

class AuthInterceptor {
    AuthRequestValidator authRequestValidator

    AuthInterceptor() {
        matchAll()
    }

    /**
     * Executed before a matched action.
     *
     * @return Whether the action should continue and execute.
     */
    boolean before() {
        return authRequestValidator.checkAccessPermission(request, response)
    }

    /**
     * Executed after the action executes but prior to view rendering.
     *
     * @return True if view rendering should continue, false otherwise.
     */
    boolean after() {
        return true
    }

    /**
     * Executed after view rendering completes.
     */
    void afterView() { }
}